package com.itjiange.listener;

import com.itjiange.constant.UserStatus;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;
import javax.servlet.http.HttpSession;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

/**
 * 监听
 *
 * @author ItJiange
 * @date 2023/10/24
 */
@WebListener
public class MyServletContextListener implements ServletContextListener {
    // 加载 web 容器时执行
    public void contextInitialized(ServletContextEvent sce) {
        ServletContext servletContext = sce.getServletContext();
        ConcurrentMap<String, HttpSession> sessionPojoMap = new ConcurrentHashMap<>();
        servletContext.setAttribute(UserStatus.LOGIN_ING, sessionPojoMap);
    }
}
